﻿/// <summary>
/// https://leetcode-cn.com/problems/first-missing-positive/
/// </summary>
public class Solution
{
    public int FirstMissingPositive(int[] nums)
    {
        var linq = (from num in nums
                    where num > 0
                    orderby num
                    select num).Distinct();
        var shouldBe = 1;
        foreach (var num in linq)
        {
            if (num != shouldBe)
                return shouldBe;
            shouldBe = num + 1;
        }
        return shouldBe;
    }
}